package com.zl.learning.thread;

public class TestVolatile {

    private static boolean initFlag = false;

    public static void main(String[] args) throws InterruptedException {
        new Thread(() -> {
            System.out.println("waiting data...");
            while (initFlag == false) {
                System.out.println("aaa");
            }
            System.out.println("success");
        }).start();
        Thread.sleep(2000);
        new Thread(() -> {
            System.out.println("准备数据");
            initFlag = true;
            System.out.println("准备完成");
        }).start();
    }
}
